/*
 * Copyright (c) 2024 Black Sesame Technologies
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef _DAL_FASTDDS_QOS_CONVERTER_HPP_
#define _DAL_FASTDDS_QOS_CONVERTER_HPP_

#include "dal/ret_type.h"
#include "dal/locator.h"
#include "dal/domain_participant.h"
#include <fastdds/dds/domain/DomainParticipant.hpp>
#include <fastdds/dds/subscriber/Subscriber.hpp>
#include <fastdds/dds/publisher/Publisher.hpp>

using namespace eprosima::fastdds::dds;

class QosConverter
{
private:
    dal_ret_t SetUnicastLocatorsToFastddsParticipantQos(SEQUENCE_BASE* seq,
                                                        DomainParticipantQos* f_qos);

    dal_ret_t SetMulticastLocatorsToFastddsParticipantQos(SEQUENCE_BASE* seq,
                                                          DomainParticipantQos* f_qos);

    void AddUnicastLocatorsToWhiteList(SEQUENCE_BASE* seq, DomainParticipantQos* f_qos);

    void LoadFlowControlProfilesFromPathToParticipantQos(DomainParticipantQos* f_qos);

    bool is_flow_controller_profiles_exist;

    std::string flow_controller_name;

protected:
    QosConverter();
    static QosConverter* singleton_;

public:
    QosConverter(QosConverter& other) = delete;
    void operator=(const QosConverter&) = delete;
    static QosConverter* GetInstance();

    dal_ret_t ConvertParticipantQosFromDalToFastdds(dal_domain_participant_qos_t* d_qos,
                                                    DomainParticipantQos* f_qos);

    dal_ret_t ConvertPublisherQosFromDalToFastdds(dal_publisher_qos_t* d_qos, PublisherQos* f_qos);

    dal_ret_t ConvertSubscriberQosFromDalToFastdds(dal_subscriber_qos_t* d_qos, SubscriberQos* f_qos);

    dal_ret_t ConvertTopicQosFromDalToFastdds(dal_topic_qos_t* d_qos, TopicQos* f_qos);

    dal_ret_t ConvertDataWriterQosFromDalToFastdds(dal_datawriter_qos_t* d_qos, DataWriterQos* f_qos);

    dal_ret_t ConvertDataReaderQosFromDalToFastdds(dal_datareader_qos_t* d_qos, DataReaderQos* f_qos);
};

#endif  // _DAL_FASTDDS_QOS_CONVERTER_HPP_